WP_Insert_Post and GUID Issue [Wordpress]

Posted by morningglory on Stack Overflow See other posts from Stack Overflow or by morningglory
Published on 2010-04-28T03:55:10Z Indexed on 2010/04/28 4:03 UTC
Read the original article Hit count: 147

Filed under:
|

Hello,

I have a posting form at my theme. I used wp_insert_post there. My code looks like this

$post = array(
      'ID' => '',
      'post_author' => $post_author,
      'post_category' => $post_category,
      'post_content' => $post_content,
      'post_title' => $post_title,
      'post_status' => 'publish',
    );  

    $post_id = wp_insert_post($post);
    $fullpost = get_post($post_id);

    wp_redirect($fullpost->guid);

Everything works fine. But when it's inserted to the database, at the GUID field, the entry format is like this permalinks_structure/id. So if my permalinks_structure is like /category/id , it become like http://www.example.com/uncategorized/1. So the problem is, if i post through wordpress admin panel, GUID of the post is http://www.example.com?p=1 . So my post database GUID become mess, because if i want to change permalinks_structure , the post which becomes from outside form will follow the structure.

What I want to do is, I want to get the GUID like that I posted through admin panel which is http://www.example.com?p=1

How can i do it ? Please point me out. Thank you.

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about php